<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
        <meta name="author" content="order by dede58.com"/>
		<title>用户注册</title>
		<link rel="stylesheet" type="text/css" href="./css/login.css">
<<<<<<< HEAD
				<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
		<script type="text/javascript" src="js/jquery.cookie.js"></script>
		<script type="text/javascript">
$(function(){
	
        $("input[name='username']").blur(function(){
        	 var username=$("input[name='username']").val();           	       	    	
            var regName = /[a-zA-Z]\w{4,16}/
            $("#name_s").empty();
                    if(username==""){                 	 
                    	$("#name_s").html("<p style='color:red;'>用户名不能为空</p>")
                    }else if (!regName.test(username)) {
                    	$("#name_s").html("<p style='color:red;'>由英文字母和数字组成的4-16位字符，以字母开头</p>")
                    } else {
                    	  $.ajax({
                 	    	 type:"post",
                 	    	 url:"json/user_UserGet",
                 	    	 data:{"userName":username},
                 	    	 dataType:"JSON",
                 	    	 success:function(result){
                 	    		 var  status=result.status
                 	    		 if (status==1) {
                                  	$("#name_s").html("<p style='color:red;'>此用户名已存在</p>")
                                  }else {
                                	  $("#name_s").html("<p style='color:green;'>OK</p>")
								}
                 	    	 }
                 	     })
                    	
                    }      	      	
        })
        
       
        $("input[name='password']").blur(function(){
        	 var userPassword=$("input[name='password']").val();
        	 $("#pwd_s").empty();
        	 var regPwd = /^\w{4,10}$/;
        	 if(userPassword==""){
        		 $("#pwd_s").html("<p style='color:red;'>密码不能为空</p>")
        	 }else if (!regPwd.test(userPassword)) {
        		 $("#pwd_s").html("<p style='color:red;'>由英文字母和数字组成的4-10位字符</p>")
			}else {
            	$("#pwd_s").html("<p style='color:green;'>OK</p>")
            }           	 
        })
        
        $("input[name='repassword']").blur(function(){
        	var userPassword=$("input[name='password']").val();
        	 var repassword=$("input[name='repassword']").val();
        	 $("#repwd_s").empty();
        	 if(repassword=="" || repassword!=userPassword ){
        			$("#repwd_s").html("<p style='color:red;'>两次输入密码不一致</p>")     		 
        	 }else {
             	$("#repwd_s").html("<p style='color:green;'>OK</p>")
             }       	        
        })
         $("input[name='tel']").blur(function(){  
        		var tel=$("input[name='tel']").val();
        	 var regPhone = /[13,15,18]\d{9}/;
        	 $("#tel_s").empty();
        	 if (tel == "" || tel.trim() == "") {
        		 $("#tel_s").html("<p style='color:red;'>手机号不能为空</p>")     	
        	 }else if (!regPhone.test(tel)) {
        		 $("#tel_s").html("<p style='color:red;'>手机号格式不对</p>")     
             } else {
            	 $("#tel_s").html("<p style='color:green;'>OK</p>")     
             }
        	 
         })
         
         $("input[name='submit']").click(function(){
        	 var boo=0;
        	 var sp_1= $("#name_s").text();
        	 var sp_2=$("#pwd_s").text();
        	 var sp_3=$("#repwd_s").text();
        	 var sp_4= $("#tel_s").text();
        	 if(sp_1=='OK'&&sp_2=='OK'&&sp_3=='OK'&&sp_4=='OK'){
        		  boo=1;
        	 }      	 
        	if(boo==1){
        		 var username=$("input[name='username']").val(); 
        		 var userPassword=$("input[name='password']").val();
        		 var tel=$("input[name='tel']").val();
        		$.ajax({
        			type:"post",
        			url:"json/user_addUser",
        			data:{"userName":username,"userPassword":userPassword,"userPhone":tel},
        			dataType:"JSON",
        			success:function(result){    			
        			    alert("注册成功")
        		  		window.location.href="login.html";
        			}
        			
        		})
        		
        	}
     

         })
         
        
        
})		
		</script>

	</head>
	<body>
		<form  method="post" >
=======

	</head>
	<body>
		<form  method="post" action="./regist.php">
>>>>>>> b9f4a6f72ab076b6badbf38ebc0d10992f0e3038
		<div class="regist">
			<div class="regist_center">
				<div class="regist_top">
					<div class="left fl">会员注册</div>
					<div class="right fr"><a href="./index.html" target="_self">小米商城</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="regist_main center">
<<<<<<< HEAD
					<div class="username">用&nbsp;&nbsp;户&nbsp;&nbsp;名:&nbsp;&nbsp;<input class="shurukuang" type="text" name="username" placeholder="请输入你的用户名"/><span id="name_s">由英文字母和数字组成的4-16位字符，以字母开头</span></div>
					<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="password" placeholder="请输入你的密码"/><span id="pwd_s">由英文字母和数字组成的4-10位字符</span></div>
					
					<div class="username">确认密码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="repassword" placeholder="请确认你的密码"/><span id="repwd_s">两次密码要输入一致哦</span></div>
					<div class="username">手&nbsp;&nbsp;机&nbsp;&nbsp;号:&nbsp;&nbsp;<input class="shurukuang" type="text" name="tel" placeholder="请填写正确的手机号"/><span id="tel_s">填写下手机号吧，方便我们联系您！</span></div>
		<!-- 			<div class="username">
						<div class="left fl">验&nbsp;&nbsp;证&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="yanzhengma" type="text" name="username" placeholder="请输入验证码"/></div>
						<div class="right fl"><img src="./image/yanzhengma.jpg"></div>
						<div class="clear"></div>
					</div> -->
				</div>
				<div class="regist_submit">
					<input class="submit" type="button" name="submit" value="立即注册" >
=======
					<div class="username">用&nbsp;&nbsp;户&nbsp;&nbsp;名:&nbsp;&nbsp;<input class="shurukuang" type="text" name="username" placeholder="请输入你的用户名"/><span>请不要输入汉字</span></div>
					<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="password" placeholder="请输入你的密码"/><span>请输入6位以上字符</span></div>
					
					<div class="username">确认密码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="repassword" placeholder="请确认你的密码"/><span>两次密码要输入一致哦</span></div>
					<div class="username">手&nbsp;&nbsp;机&nbsp;&nbsp;号:&nbsp;&nbsp;<input class="shurukuang" type="text" name="tel" placeholder="请填写正确的手机号"/><span>填写下手机号吧，方便我们联系您！</span></div>
					<div class="username">
						<div class="left fl">验&nbsp;&nbsp;证&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="yanzhengma" type="text" name="username" placeholder="请输入验证码"/></div>
						<div class="right fl"><img src="./image/yanzhengma.jpg"></div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="regist_submit">
					<input class="submit" type="submit" name="submit" value="立即注册" >
>>>>>>> b9f4a6f72ab076b6badbf38ebc0d10992f0e3038
				</div>
				
			</div>
		</div>
		</form>
	</body>
</html>